<template>
  <el-form
    :model="models"
    :disabled="disabled"
    label-width="150px"
    class="qm-gen-form"
    
  >
    <el-row >
      <el-col :span="12">
        <el-form-item label="指定部门：" >
          <span>{{models.model.departmentId | filterDept}}</span>
        </el-form-item>
      </el-col>
      <el-col :span="12">
        <el-form-item label="指定用户：" >
          <span>{{models.model.usersName}}</span>
        </el-form-item>
      </el-col>
    </el-row>

    <el-row>
      <el-col :span="24">
        <el-form-item label="指定账号：" >
          <span>{{models.model.accounts}}</span>
        </el-form-item>
      </el-col>
    </el-row>

    
    <el-row >
      <el-col :span="12">
        <el-form-item label="消息类型：" >
          <span>{{ models.model.messageType | DictItem(controlData.messageTypes,'name','typeId')}}</span>
        </el-form-item>
      </el-col>
      <el-col :span="12">
        <el-form-item label="应用系统：" >
         <span>{{ models.model.systemId | DictItem(controlData.messageSystem,'systemName','systemId')}}</span>
        </el-form-item>
      </el-col>
    </el-row>
    <el-row >
      <el-col :span="12">
        <el-form-item label="优先级：" >
          <span>{{ models.model.priority | DictItem(controlData.messagePriroty,'key','value')}}</span>
        </el-form-item>
      </el-col>
      <el-col :span="12">
        <el-form-item label="计划发送时间：">
         <span>{{models.model.planTime | date("yyyy-MM-dd")}}</span>
        </el-form-item>
      </el-col>
    </el-row>
    <el-row>
      
      <el-col :span="24" >
        <el-form-item label="标题：" >
          <span>{{models.model.title}}</span>
        </el-form-item>
      </el-col>
    </el-row>
    <el-row>
      
       <el-col :span="24" >
        <el-form-item label="内容：" >
          <span>{{models.model.body}}</span>
        </el-form-item>
      </el-col>
    </el-row>
  </el-form>
</template>

<script>
import request from "@/utils/request";
import _ from "lodash";
let that = null;
export default {
  name: "MessageSysMessageCreate",
  props: {
    models: Object,
    controlData: Object,
    disabled: Boolean,
    pageAction: String
  },
   filters: {
    filterDept(val) {
        
        const dept=that.deptTree.find(item=>{
          return item.id===val
        })
        if(dept)
        {
          return dept.text;
        }
        return null
    
    }
  },
  beforeCreate(){
    if (!that) {
      that = this;
    }
  },
  data() {
    return {
      selectedDeptId: "",
      deptTree: []
    };
  },
  created() {
    this.getDeptTreeData();
  },
  methods: {
    getDeptTreeData() {
      request({
        url: "/admin/sysDepartment/selectDep",
        method: "get",
        params: {}
      }).then(r => {
        this.deptTree = r || [];
      });
    },
    getUsers(departmentId) {
      request({
        url: "/message/sysMessage/getUsersByDepartmentId",
        method: "post",
        data: { departmentId: departmentId }
      }).then(rlt => {
        this.controlData.userList = rlt || [];
      });
    }
  }
};
</script>

<style scoped>
  
</style>
